package com.example.androiddev.base;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;


import com.example.androiddev.R;
import com.example.commonlib.listener.NoDoubleClickListener;
import com.gyf.immersionbar.ImmersionBar;

/**
 * Created by zxw.
 * CreateDate: 2019/12/18 17:14
 * Description: 基础界面
 */
public class BaseActivity extends AppCompatActivity {


    protected TextView title;

    protected View back;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ImmersionBar.with(this).init();
        setContentView(getContentView());
        initView();
        initData();
    }

    protected void initData() {

    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    protected void initView() {
        title = findViewById(R.id.page_title);
        back = findViewById(R.id.back);
        back.setOnClickListener(new NoDoubleClickListener() {
            @Override
            public void onNoDoubleClick(View v) {
                onBackPressed();
            }
        });
    }

    protected int getContentView() {
        return -1;
    }

    protected void setTitle(String titleName) {
        if (null != title) {
            title.setText(titleName);
        }
    }

}
